BudgetItemList

class BudgetItemList @JvmOverloads constructor(val budget: Budget, itemList: List<BudgetItem> = budget.allItems) : Iterable<BudgetItem>

this contains a list of budget items associated with a budget and is used to perform calculations and interactions with the items of the list without having to query the main data model for every budget-specific interaction.

This can also be used to create an editable copy of a budget so that changes can be aborted or committed rather than synced individually.

Constructors

Link copied to clipboard
constructor(budget: Budget, itemList: List<BudgetItem> = budget.allItems)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
fun getActualAmount(account: Account, budgetPeriod: BudgetPeriod): Long

Return the actual amount for a specific category in a month. Because of a bug in the Calendar class, date is not reset to the first day of the month so it must be passed in already set correctly.

Link copied to clipboard

Returns the actual amount for all categories in the given period. Optimised for performance using a one-pass sweep.

Link copied to clipboard
fun getBudgetedAmount(account: Account?, budgetPeriod: BudgetPeriod): Long

Return the budgeted amount for a specific category in a month. Because of a bug in the Calendar class, date is not reset to the first day of the month so it must be passed in already set correctly.

Returns the budgeted amount for all categories in the given period

Link copied to clipboard

Get the budget items for the given account in the given budget period.

Link copied to clipboard

Get the budget items with the given transfer account whose date interval overlap with the given date range.

Link copied to clipboard

Get the budget item at the given position in the list

Link copied to clipboard
fun indexOf(item: BudgetItem): Int

Return the position in the item list of the given item

Link copied to clipboard
open operator override fun iterator(): MutableIterator<BudgetItem>
Link copied to clipboard
Link copied to clipboard

Precompute and cache actual amounts for the given date ranges. Safe to call from a background thread — later reads on the EDT become instant lookups.

Link copied to clipboard
fun reload()

Reload by rescanning the data model for budget items. If this is an editable list then this resets the list to make it no longer able to be reverted.

Link copied to clipboard

Remove the given budget item from the list. Returns true if the item was in the list.

Link copied to clipboard
fun saveEdits()
Link copied to clipboard
fun setBudgetedAmount(account: Account, amount: Long, budgetPeriod: BudgetPeriod)

Sets the budgeted amount for a given Account in a given BudgetPeriod.

Link copied to clipboard
Link copied to clipboard

Get a new array of the budget items contained in this list